﻿Imports WiremetModel.Entities.SupplyOrders
Imports CrystalDecisions.CrystalReports.Engine
Public Class DieOrderReportService
    Inherits OrderReportService

    Public Function GenerateReport(ByVal dieOrder As DieOrder) As ReportDocument

        Dim dieOrderReport As New DieOrderReport()

        Dim dieOrderReportData As New List(Of DieOrderLineReportDataRow)
        For Each dieOrderLine As DieOrderLine In DieOrder.OrderLines.OrderBy(Function(x) x.Diameter)
            dieOrderReportData.Add(New DieOrderLineReportDataRow With {
                                    .Id = dieOrderLine.Id,
                                    .Diameter = dieOrderLine.Diameter.ToString(),
                                    .DiameterToleranceMinus = dieOrderLine.DiameterToleranceMinus.ToString(),
                                    .DiameterTolerancePlus = dieOrderLine.DiameterTolerancePlus.ToString(),
                                    .CasingDiameter = dieOrderLine.CasingDiameter.ToString(),
                                    .CasingHeight = dieOrderLine.CasingHeight.ToString(),
                                    .Quantity = dieOrderLine.Quantity
                               })
        Next


        dieOrderReport.SetDataSource(dieOrderReportData)
        SetParameterValues(DieOrder, dieOrderReport)
        Return dieOrderReport

    End Function

End Class
